<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
        <meta charset="UTF-8">
    </head>
    <script src="./js/jquery.min.js"></script>
    <body>
        <input type="text" id="input1">
        <input type="button" value="测试" id="test">
        <script type="text/javascript">
           
           $(document).ready(v=>{

               $("#test").click(v=>{
                    var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                    let a = $('#input1').val()

                    let money = ''
                    if(reg.test(a)){
                        console.log('7788')
                        console.log(yuanToFen(a))
                    }else{
                        alert('格式错误')
                    }
               })
               function yuanToFen(item){
                    money = parseFloat(item).toFixed(2)*100
                    money = money.toFixed(0)
                    return money
               }
           })
        </script>
    </body>
</html>
